home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / SirTommy.dxr / Internal_1_stock cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  3.0 KB  |  99 lines

  1. property spriteNum, motion, undercard, location
  2. global shuffledCards, stock, foundation, tableau, equal, currentsel, godlist, getlist, points
  3.  
  4. on beginSprite me
  5.   shuffle()
  6.   stock = new(script("card pile"))
  7.   undercard = sprite(9)
  8.   location = sprite(spriteNum).loc
  9.   repeat while shuffledCards.count > 0
  10.     sprite(spriteNum).member = member(shuffledCards[1].rank & "_" & shuffledCards[1].suit, "playing cards")
  11.     shuffledCards.deleteAt(1)
  12.     stock.addCard(spriteNum)
  13.   end repeat
  14. end
  15.  
  16. on shuffle me
  17.   ranks = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
  18.   suits = ["hearts", "diamonds", "clubs", "spades"]
  19.   unshuffledCards = []
  20.   shuffledCards = []
  21.   repeat with rank in ranks
  22.     repeat with suit in suits
  23.       unshuffledCards.add([#rank: rank, #suit: suit])
  24.     end repeat
  25.   end repeat
  26.   repeat while unshuffledCards.count > 0
  27.     shuffledCards.add(unshuffledCards[random(unshuffledCards.count)])
  28.     unshuffledCards.deleteOne(shuffledCards[shuffledCards.count])
  29.   end repeat
  30. end
  31.  
  32. on mouseDown me
  33.   if stock.getcardcount() > 0 then
  34.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  35.     sprite(spriteNum).locZ = spriteNum + 1000
  36.     getlist = stock
  37.     if stock.getcardcount() > 1 then
  38.       undercard.member = member(stock.cards[stock.getcardcount() - 1].membername, "playing cards")
  39.     else
  40.       if stock.getcardcount() = 1 then
  41.         undercard.member = member("empty", "playing cards")
  42.       end if
  43.     end if
  44.     motion = timeout(string(spriteNum) && "motion").new(5, #moving, me)
  45.   end if
  46. end
  47.  
  48. on moving me
  49.   if the mouseDown then
  50.     sprite(spriteNum).loc = the mouseLoc
  51.   else
  52.     if the mouseUp then
  53.       sprite(spriteNum).locZ = spriteNum
  54.       motion.forget()
  55.       abort()
  56.     end if
  57.   end if
  58. end
  59.  
  60. on mouseUp me
  61.   if equal then
  62.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  63.     sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  64.     godlist.addCard(currentsel)
  65.     sprite(spriteNum).loc = location
  66.     stock.cards.deleteOne(stock.getlastcard())
  67.     if objectp(foundation[sprite(currentsel).row]) then
  68.       points = points + 10
  69.     end if
  70.     if objectp(tableau[sprite(currentsel).row]) then
  71.       repeat with i = 71 to 74
  72.         if tableau[sprite(i).row].getcardcount() = 0 then
  73.           next repeat
  74.         end if
  75.         sprite(i).loc = tableau[sprite(i).row].getlastcard().location
  76.       end repeat
  77.     end if
  78.     if stock.getcardcount() > 0 then
  79.       sprite(spriteNum).member = member(stock.getlastcard().membername, "playing cards")
  80.     else
  81.       if stock.getcardcount() = 0 then
  82.         sprite(spriteNum).member = member("empty", "playing cards")
  83.         undercard.member = member("empty", "playing cards")
  84.       end if
  85.     end if
  86.     equal = 0
  87.     currentsel = 0
  88.     godlist = VOID
  89.     getlist = VOID
  90.     checkwin()
  91.   else
  92.     if not equal then
  93.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  94.       getlist = VOID
  95.       sprite(spriteNum).loc = location
  96.     end if
  97.   end if
  98. end
  99.